package com.caine.androidtask.ls29;


import com.caine.androidtask.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ImageView;
import android.widget.Toast;
import android.view.View.OnClickListener;

public class Settings extends Activity {

	ImageView iv_search;
	ImageView iv_changview;
	ViewGroup group;
	View view1;
	View view2;
	boolean flags = false;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        setContentView(R.layout.caine_ls29_gride);
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);
        iv_search = (ImageView) findViewById(R.id.ic_menu_search_icon);
        iv_changview = (ImageView) findViewById(R.id.ic_menu_m_icon);
        iv_search.setOnClickListener(onclick);
        iv_changview.setOnClickListener(onclick);
        view1 = findViewById(R.id.ly1);
        view2 = findViewById(R.id.ly2);
	    group = (ViewGroup) findViewById(R.id.ic_settins_gride_layout);
	}
	
	private OnClickListener onclick = new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			switch(v.getId()){
			case R.id.ic_menu_m_icon:
				if(flags){
					loadDefaultTheme(flags);
				}else{
					loadDefaultTheme(flags);
				}
				break;
			case R.id.ic_menu_search_icon:
				Intent intent = new Intent(Intent.ACTION_VIEW);
				intent.setClassName("com.android.quicksearchbox", "com.android.quicksearchbox.SearchActivity");
				startActivity(intent);
				break;
			default:
			
			}
		}
	};
	
	void loadDefaultTheme(boolean flag){
		group.removeView(view1);
		group.removeView(view2);
		if(flag){
			group.addView(view1);
		}else{
			group.addView(view2);
		}
		flags = !flags;
	}
}
